home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Files
/
Locations
/
TentativeFile.cp
< prev
next >
Wrap
Text File
|
2000-06-23
|
1KB
|
63 lines
// TentativeFile.cp
#ifndef TentativeFile_h
#include "TentativeFile.h"
#endif
TentativeFile::TentativeFile( const FileLocation& theLocation,
FileType type,
ScriptID script )
: location( theLocation ),
committed( false )
{
CreateFile( location, type, script );
}
TentativeFile::TentativeFile( const FileLocation& theLocation,
FileType type,
FileSignature creator,
ScriptID script )
: location( theLocation ),
committed( false )
{
CreateFile( location, type, creator, script );
}
TentativeFile::~TentativeFile()
{
if ( committed )
return;
try
{
DeleteFile( location );
}
catch (...)
{
Assert( 0 );
}
}
void TentativeFile::CommitReplacing( const FileLocation& toReplace )
{
Assert( !committed );
SwapFiles( location, toReplace );
committed = true;
DeleteFile( toReplace );
}
FileLocation TentativeFile::GoodLocation( Volume volume,
ConstPString nameHint )
{
FileLocation result( Directory::FindOrMake( kChewableItemsFolderType, volume ),
nameHint );
result.FindUnusedName();
return result;
}
FileLocation TentativeFile::GoodLocation( const FileLocation& hint )
{
return GoodLocation( hint.Volume(), hint.Name() );
}